package br.gov.ce.fortaleza.cti.util;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class ReceiverSMS  {

	public static void main(String[] args) {

		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();

			Statement smnt     = null;;
			String dbHost      = "localhost";
			String database    = "pmf_desv";
			String dbUsername  = "sgf";
			String dbPassword  = "sgf";
			String smsReceiver = "+558591482315";
			String message  = "Hello world";

			String dbUrl = "jdbc:postgresql://"+ dbHost +"/" + database +"";

			Connection conn = DriverManager.getConnection(dbUrl, dbUsername, dbPassword);
			smnt = conn.createStatement();

			String sqlInsert =
					"INSERT INTO smsapp.messageout (receiver,msg,status) VALUES '" + smsReceiver + "','"+ message +"','send')";

			if(smnt.executeUpdate(sqlInsert) != 0){
				System.out.println("OK");

			}
			else{
				System.out.println("ERROR");
			}

			smnt.close();
			conn.close();
		}catch(Exception ex){
			System.out.println("Exception: " + ex.getMessage());
		}
	}

}

